From 99aa55df4150c2c00741581065be34cca33357dc Mon Sep 17 00:00:00 2001 From: mseri Date: Wed, 26 Aug 2015 15:37:07 +0100 Subject: [PATCH] Fix for issue #1942 'cargo run fails if called from executable folder' It maybe a hacky way but I think that changing `util::without_prefix` is a bad approach. Maybe modify `process.build_command` could be another possible approach. --- src/cargo/ops/cargo_run.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cargo/ops/cargo_run.rs b/src/cargo/ops/cargo_run.rs index 79bd505c5..6b9d285d7 100644 --- a/src/cargo/ops/cargo_run.rs +++ b/src/cargo/ops/cargo_run.rs @@ -48,7 +48,9 @@ pub fn run(manifest_path: &Path, let compile = try!(ops::compile(manifest_path, options)); let exe = &compile.binaries[0]; let exe = match util::without_prefix(&exe, config.cwd()) { - Some(path) => path, + Some(path) => if path.as_os_str() == path.file_name().unwrap() { &**exe } + else { path }, // workaround for being able to use + // `cargo run` from the executable path itself None => &**exe, }; let mut process = try!(compile.target_process(exe, &root)) -- 2.30.2